/************************************* * File: Rectangle.cpp * Author: Katherine Gibson * Date: 2/16/2016 * Section: N/A * E-mail: k38@umbc.edu * Description: * This file contains the * definition for a rectangle class *************************************/ #include "Rectangle.h" #include using namespace std; /* because this is the DEFINTION, we don't need things like the member variables or the "class" keyword */ /**********************************/ /* methods of the Rectangle class */ /**********************************/ // CalcArea // returns area of Rectangle int Rectangle::CalcArea(void){ int area = m_width * m_height; return area; } // CalcPerim // returns perimteter of Rectangle int Rectangle::CalcPerim(void){ return 2 * (m_height + m_width); } // Rotate // switches m_width and m_height to "rotate" Rectangle void Rectangle::Rotate() { int temp = m_height; m_height = m_width; m_width = temp; } // IsSquare // returns if m_width and m_height are equal bool Rectangle::IsSquare() { if (m_height == m_width) { return true; } else { return false; } /* We could also accomplish the above in one line: return (m_height == m_width); */ }